<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户列表</title>
<link href="/resources/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="/resources/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="/resources/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

<link href="/resources/lib/jquery_plug/plupload-2.1.2/js/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" rel="stylesheet" media="screen">
<link href="/resources/lib/jquery_plug/jquery-ui/themes/cupertino/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="/resources/lib/jquery/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="/resources/lib/jquery_plug/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="/resources/lib/jquery_plug/layer-v1.8.5/layer/layer.min.js" type="text/javascript"></script>
<script src="/resources/lib/jquery_plug/plupload-2.1.2/js/plupload.full.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/resources/lib/jquery_plug/plupload-2.1.2/js/i18n/zh_CN.js" charset="UTF-8"></script>
<script src="/resources/lib/jquery_plug/plupload-2.1.2/js/jquery.ui.plupload/jquery.ui.plupload.min.js" type="text/javascript"></script>

<script src="/resources/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ex/ligerGrid.showFilter.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ex/ligerFilterEx.js" type="text/javascript"></script>
<script src="/resources/js/selectData.js" type="text/javascript"></script>
<script src="/resources/js/jsF7.js" type="text/javascript"></script>
<script type="text/javascript">
    var bool_data = [
                     { id: '1', value: '1', text: '是' },
                     { id: '0', value: '0', text: '否' }
                 ];
        var $grid;
        var form;
        $(function (){
        	//创建查询对象
        	/* form = $("#form2").ligerForm({
            	  inputWidth: 150, labelWidth: 80, space: 40,
                  fields: [ 
                      { label: "用户名", name: "userName", newline: false, type: "text", validate: {minlength: 5 } },
                      { label: "是否可用", name: "status", newline: false, type: "select",editor: {data:bool_data}}
                  ]
            });  */
            //创建表格对象 高级查询editor 识别编辑器有：combobox date number string
            $grid = $("#maingrid").ligerGrid({
                columns: [
                { name: 'uuid', hide:true,type:"text"},
                { display: '用户名', name: 'userName', width: 100,type:"text"},
                { display: '真实名', name: 'trueName', width: 100,type:"text"},
                { display: '电话', name: 'phone', width: 100,type:"text"},
                { display: '手机', name: 'mobile', width: 100,type:"text"},
                { display: '邮箱', name: 'mail', width: 200,type:"text"}
                
/*                 { display: '是否到期', name: 'isAccountNonExpired', width: 100,type: "text",editor: { type:'combobox',options:{data:bool_data,valueField:'value',textField:'text'}},
                	render: function (item)
                     {
                         if (item.accountNonExpired) return '是';
                         return '否';
                     }},
                { display: '是否锁定', name: 'isAccountNonLocked', width: 100,type: "text",editor: { type:'combobox',options:{data:bool_data,valueField:'value',textField:'text'}},
                     render: function (item)
                     {
                         if (item.accountNonLocked) return '是';
                         return '否';
                     }},
                { display: '是否可用', name: 'isEnabled', width: 100,type: "text",editor: { type:'combobox',options:{data:bool_data,valueField:'value',textField:'text'}},
                	 render: function (item)
                     {
                         if (item.enabled) return '是';
                         return '否';
                     }}, */
                ],
                autoFilter:true,
                width: '100%', pageSizeOptions: [5, 10, 15, 20], height: '100%',
                checkbox: true,headerRowHeight:22, rowHeight:22, rownumbers:true,
                url:'/sysUser/listData',
                onLoadData:onloadData,
                onDblClickRow:onDblClickRow,
                toolbar: { items: [
                                   { text: '新增', click: addClick, icon: 'add' },
                                   { line: true },
                                   { text: '修改', click: alertClick, icon: 'modify' },
                                   { line: true },
                                   { text: '删除', click: delClick, icon: 'delete' }
                                  /*  { line: true },
                                   { text: '导入', click: importClick, icon: 'bluebook' }
 */                                   ]
                                   }
            });

        });
        //添加
        function addClick(item){
        	f_addTab('operationLog_add','新增用户','/sysUser/addSysUser');
        }
        //双击事件(查看)
        function onDblClickRow(data, rowindex, rowobj){
        	f_addTab('operationLog_view','查看用户','/sysUser/viewSysUser?uuid='+data.uuid);

        }
        
        //删除
        function delClick(){
        	var rows = $grid.getSelectedRows();
        	if(rows == null || rows.length < 1){
        		$.ligerDialog.error("请至少选择一行数据");
        		return;
        	}
    		$.ajax({ 
    			url: '/sysUser/delSysUser', 
    			data:{rows : JSON.stringify(rows)}, 
    			type: "post", 
    			dataType:'json',
    			cache : false, 
    			success: function(data){
    				$.ligerDialog.success(data.message,'信息',function(){
    		        	 $grid.reload();
    				});
    			},
    	        error: function (message) {
    	            $.ligerDialog.error("删除失败");
    	        }
    	});
        }
        //修改
        function alertClick(){
        	var rows = $grid.getSelectedRows();
        	if(rows == null || rows.length < 1 || rows.length != 1){
        		$.ligerDialog.error("请选择一条要修改的数据");
        		return;
        	}
        	f_addTab('operationLog_alert','修改用户','/sysUser/alterSysUser?uuid='+rows[0].uuid);
        }
        
        //查询
        function viewClick(){
        	//重新加载grid
        	 $grid.reload();
        }
        
      //获取数据前添加过滤条件
      function onloadData(){
    	/*   var cond = JSON.stringify(form.getData());
    	  this.options.parms.cond= cond;
    	  this.options.parms.temp= true; */
    	/*   applay(this.options.parms, [{ name: "cond", value: cond, temp: true }]); */
    	 //this.set('parms', [{ name: "cond", value: cond, temp: true }]);
      }
  	  //添加窗口
      function f_addTab(tabid,text, url){
  		this.parent.f_addTab(tabid,text, url);
      }
  	  
  	  
      function importClick(item){
        	var pageii = $.layer({
        	    type: 1,
        	    title: false,
        	    area: ['600', '300'],
        	    border: [0], //去掉默认边框
        	    //shade: [0], //去掉遮罩
        	    closeBtn: [0, true], //去掉默认关闭按钮
        	   // shift: 'left', //从左动画弹出
        	    page: {
        	        html: "<div id='uploader' ></div>"
        	    }
        	});
        	var loadi = null;
        	  $("#uploader").plupload({
        	        // General settings
        	        runtimes : 'html5,flash,silverlight,html4',
        	        url : "/sysUser/importSysUserExcel",
        	 
        	        // Maximum file size
        	        max_file_size : '50mb',
        	        multi_selection :false,
        	 
        	        chunk_size: '1mb',
        	 
        	        // Resize images on clientside if we can
        	         resize : {
        	            width : 500,
        	            height : 300,
        	            quality : 90,
        	            crop: true // crop to exact dimensions
        	        },
        	 
        	        // Specify what files to browse for
        	        filters : [
        	                   {title : "Excel files", extensions : "xls,xlsx"}
        	            /* {title : "Image files", extensions : "jpg,gif,png"},
        	            {title : "Zip files", extensions : "zip,avi"} */
        	        ],
        	        // Rename files by clicking on their titles
        	        rename: true,
        	         
        	        // Sort files
        	        sortable: true,
        	 
        	        // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
        	        dragdrop: true,
        	 
        	        // Views to activate
        	        views: {
        	            list: true,
        	            thumbs: true, // Show thumbs
        	            active: 'thumbs'
        	        },
        	        init:{
        	        	FilesAdded: function(up, files) {
        	        		$.each(up.files, function (i, file) {
        	  	                if (up.files.length <= 1) {
        	  	                    return;
        	  	                }
        	  	                up.removeFile(file);
        	  	            });
        	            },
        	            FileUploaded: function(up, file, info) {
        	            	var re = JSON.parse(info.response);
        	            	if(re && re.code=='SUCCESS'){
        	            		$('#uploader').plupload('notify', 'info', re.message);
        	            	}else{
        	            		$('#uploader').plupload('notify', 'error', re.message);
        	            	}
        	            	if(loadi){
        	            		layer.close(loadi);
        	            	}
        	                console.log(info);
        	            },
        	            BeforeUpload: function(up, file) {
        	                // Called right before the upload for a given file starts, can be used to cancel it if required
        	            	loadi =layer.load('数据处理中…');
        	            },
        	        },
        	 
        	        // Flash settings
        	        flash_swf_url : '/resources/lib/jquery_plug/plupload-2.1.2/js/Moxie.swf',
        	     
        	        // Silverlight settings
        	        silverlight_xap_url : '/resources/lib/jquery_plug/plupload-2.1.2/js/Moxie.xap'
        	    }); 
        	/*   var uploader = $("#uploader").pluploadQueue();

        	  uploader.bind('FilesAdded', function(up, files) {   
        		  $.each(up.files, function (i, file) {
  	                if (up.files.length <= 1) {
  	                    return;
  	                }
  	                up.removeFile(file);
  	            });
        	    up.refresh(); // Reposition Flash/Silverlight   
        	   });    */
        	 //openNewWindow('导入Excel:',400,450,"/material/toExcelImport",{url:'/material/importMterialExcel'});
        }
    </script>
</head>
<body  style="padding:10px">
    <div id="maingrid"></div> 
</body>
</html>
